package hied.cleaning;

import java.util.regex.Pattern;

import hied.Knowledge;

public class Cleaner {
	private Knowledge knowledge;
	private static final Pattern TOKENIZER = Pattern.compile("\\s+");

	public Cleaner(Knowledge knowledge) {
		this.knowledge = knowledge;
	}

	public String clean(String txt) {
		String[] incorrectWords = this.tokenize(txt);
		CorrectForms correctForms = this.findCorrectForms(incorrectWords, knowledge);
		return correctForms.rebuild();
	}

	private CorrectForms findCorrectForms(String[] incorrectWords, Knowledge knowledge) {
		return new CorrectForms(incorrectWords, knowledge);
	}

	private String[] tokenize(String txt) {
		return TOKENIZER.split(txt);
	}
}
